package org.example.pro1.service;

import org.example.pro1.Student;
import org.example.pro1.dao.StudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class StudentServiceImpl implements StudentService {
    private final StudentDao studentDao;

//    @Autowired    //可以省略  原因：如果只有一个构造器，那么@Autowired可以省略
    //为什么可以省略？因为Spring会自动注入
    //如果有多个构造器，那么@Autowired就不能省略
    public StudentServiceImpl(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    @Override
    public List<Student> getAllStudents() {
        return studentDao.findAllStudents();
    }
}
